#include <climits>
#include <iostream>
#include <queue>
#include <cstring>
using namespace std;
 
int m = 0, n = 0;
int dx[4] = {0, 0, -1, 1};
int dy[4] = {1, -1, 0, 0};
int dist[31][31];
 
void bfs(vector<vector<char>>& arr, int sr, int sc)
{
    queue<pair<int, int>> q;
    q.push({sr, sc});
    while(q.size())
    {
        auto [a, b] = q.front();
        q.pop();
        for(int i = 0; i < 4; ++i)
        {
            int x = a + dx[i], y = b + dy[i];
            if(x >= 1 && x <= m && y >= 1 && y <= n && dist[x][y] == -1 && arr[x][y] != '*')
            {
                dist[x][y] = dist[a][b] + 1;
                if(arr[x][y] != 'e')
                    q.push({x, y});
            }
        }
    }
}
 
int main()
{
    memset(dist, -1, sizeof(dist));
    cin >> m >> n;
    vector<vector<char>> arr(m + 1, vector<char>(n + 1));
    int sr = 0, sc = 0;
    for(int i = 1; i <= m; ++i)
    {
        for(int j = 1; j <= n; ++j)
        {
            cin >> arr[i][j];
            if(arr[i][j] == 'k')
                sr = i, sc = j;
        }
    }
    dist[sr][sc] = 0;
    bfs(arr, sr, sc);
    
    int cnt = 0, minStep = INT_MAX;
    for(int i = 1; i <= m; ++i)
    {
        for(int j = 1; j <= n; ++j)
        {
            if(arr[i][j] == 'e' && dist[i][j] != -1)
            {
                ++cnt;
                minStep = min(minStep, dist[i][j]);
            }
        }
    }
    if(cnt == 0)
        cout << -1 << endl;
    else
        cout << cnt << " " << minStep << endl;
    return 0;
}
 
/*
6 8
e . * . * e . *
. * * . * . * e
. . * k * * . .
* * * . * . e *
. * * . * . * *
* . . . . . . e
*/